#include <bits/stdc++.h>
using namespace std;
int d[10010], n;
int main()
{
	cin >> n;
	d[1] = 0, d[2] = 1;
	for(int i = 3; i <= n; i++)
		d[i] = (i - 1) * (d[i-1] + d[i-2]);
	cout << d[n];
	return 0;
}